/********************************************************************
	created:	2008/12/21
	created:	21:12:2008   22:53
	filename: 	g:\Projects On Develop\board-game\protype\BattleLine\BattleLine\BattleLineRegionManager.cpp
	file path:	g:\Projects On Develop\board-game\protype\BattleLine\BattleLine
	file base:	BattleLineRegionManager
	file ext:	cpp
	author:		Ray Xi
	
	purpose:	Manage the region set
*********************************************************************/
#include "StdAfx.h"
#include "BattleLineRegionManager.h"

CBattleLineRegionManager::CBattleLineRegionManager(void)
{
}

CBattleLineRegionManager::~CBattleLineRegionManager(void)
{

}

void CBattleLineRegionManager::Init()
{
	CGameEntityAsset::Init();

	CBattleLineRegion* pRegion;
	for(int i = 0;i < 9;i++)
	{
		pRegion = new CBattleLineRegion();
		m_oGameEntityList.push_back(pRegion);
	}

	for(vector<CGameEntity*>::iterator it = m_oGameEntityList.begin();it != m_oGameEntityList.end();it++)
	{
		(*it)->Init();
		//it could be
		//((CBattleLineRegion*)(*it))->Init(5); //to enable more troops per region;
	}
}

void CBattleLineRegionManager::Update(float fTime)
{
	CGameEntityAsset::Update(fTime);

	for(vector<CGameEntity*>::iterator it = m_oGameEntityList.begin();it != m_oGameEntityList.end();it++)
	{
		(*it)->Update(fTime);
	}
}

void CBattleLineRegionManager::Render()
{
	CGameEntityAsset::Render();

	for(vector<CGameEntity*>::iterator it = m_oGameEntityList.begin();it != m_oGameEntityList.end();it++)
	{
		(*it)->Render();
	}
}

void CBattleLineRegionManager::Deinit()
{
	for(vector<CGameEntity*>::iterator it = m_oGameEntityList.begin();it != m_oGameEntityList.end();it++)
	{
		(*it)->Deinit();
		delete (*it);
	}
	m_oGameEntityList.clear();

	CGameEntityAsset::Deinit();
}